package com.itheima.controller;

import com.itheima.service.db.TestSoulService;
import com.itheima.vo.AnswersVo;
import com.itheima.vo.ReportVo;
import com.itheima.vo.TopicVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class TestSoulController {

    @Autowired
    private TestSoulService testSoulService;

    //查询问卷
    @GetMapping("/testSoul/{userId}")
    public List<TopicVo> queryTestSoul(@PathVariable Long userId)
    {
        return testSoulService.queryTestSoul(userId);
    }

    //提交问卷
    @PostMapping("/testSoul")
    Long saveTestSoul(@RequestBody AnswersVo answersVo, @RequestParam("userId") Long userId){
        return testSoulService.saveTestSoul(answersVo,userId);
    }

    //查询报告
    @GetMapping("/testSoul/{id}/{userId}")
    ReportVo queryReport(@PathVariable Long id, @PathVariable Long userId){
        return testSoulService.queryReport(id,userId);
    };
}
